const { resolve } = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin")
const MdToHtmlPlugin = require("./plugins/md-to-html-plugin")

module.exports = {
    mode: 'development',

    entry: resolve(__dirname, 'src/app.js'),

    output: {
        path: resolve(__dirname, 'dist'),
        filename: 'app.js'
    },

    devtool: 'source-map',
    
    module: {
        rules: [
            {
                test: /\.tpl$/g,
                use: [
                    'babel-loader',
                    {
                        'loader': resolve(__dirname, './loaders/tpl-loader'),
                        options: {
                            log: true
                        }
                    }
                ]
            }
        ]
    },

    plugins: [
        new HtmlWebpackPlugin({
            template: resolve(__dirname, 'index.html')
        }),

        new MdToHtmlPlugin({
            template: resolve(__dirname, 'test.md'),
            filename: 'test.html'
        })
    ],

    devServer: {
        port: 3001
    }
}